﻿namespace Journey.Adapter
{
    /// <summary>
    /// 类型自动映射适配器。
    /// </summary>
    public interface ITypeAdapter
    {
        /// <summary>
        /// 对象映射。
        /// </summary>
        /// <typeparam name="TTarget">目标类型。</typeparam>
        /// <param name="source">源对象。</param>
        /// <returns>目标对象。</returns>
        TTarget Adapt<TTarget>(object source)
            where TTarget : class,new();

        /// <summary>
        /// 对象映射。
        /// </summary>
        /// <typeparam name="TSource">源类型。</typeparam>
        /// <typeparam name="TTarget">目标类型。</typeparam>
        /// <param name="source">源对象。</param>
        /// <returns>目标对象。</returns>
        TTarget Adapt<TSource, TTarget>(TSource source)
            where TTarget : class,new()
            where TSource : class;
    }
}